import request from "@/utils/request";

// 查询角色列表
export function listRole(query) {
  return request({
    url: "/v1/system/role/list",
    method: "get",
    params: query,
  });
}

// 查询角色详细
export function getRole(role_id) {
  return request({
    url: "/v1/system/role/getById",
    method: "post",
    data: { role_id },
  });
}

// 新增角色
export function addRole(data) {
  return request({
    url: "/v1/system/role/add",
    method: "post",
    data: data,
  });
}

// 修改角色
export function updateRole(data) {
  return request({
    url: "/v1/system/role/update",
    method: "post",
    data: data,
  });
}

// 角色数据权限
export function dataScope(data) {
  return request({
    url: "/v1/system/role/dataScope",
    method: "put",
    data: data,
  });
}

// 角色状态修改
export function changeRoleStatus(role_id, status) {
  const data = {
    role_id,
    status,
  };
  return request({
    url: "/v1/system/role/changeStatus",
    method: "post",
    data: data,
  });
}

// 删除角色
export function delRole(role_id) {
  return request({
    url: "/v1/system/role/delete",
    method: "post",
    data: { role_id },
  });
}

// 删除角色
export function delRoleByIds(ids) {
  return request({
    url: "/v1/system/role/deleteByIds",
    method: "post",
    data: { ids },
  });
}

// 查询角色已授权用户列表
export function allocatedUserList(data) {
  return request({
    url: "/v1/system/role/authUser/allocatedList",
    method: "post",
    data
  });
}

// 查询角色未授权用户列表
export function unallocatedUserList(data) {
  return request({
    url: "/v1/system/role/authUser/unallocatedList",
    method: "post",
    data: data,
  });
}

// 取消用户授权角色
export function authUserCancel(data) {
  return request({
    url: "/v1/system/role/authUser/cancelUser",
    method: "post",
    data: data,
  });
}

// 批量取消用户授权角色
export function authUserCancelAll(data) {
  return request({
    url: "/v1/system/role/authUser/batchCancelUser",
    method: "post",
    data,
  });
}

// 授权用户选择
export function authUserSelectAll(data) {
  return request({
    url: "/v1/system/role/authUser/batchAddUser",
    method: "post",
    data,
  });
}

// 根据角色ID查询部门树结构
export function deptTreeSelect(role_id) {
  return request({
    url: "/v1/system/role/deptTree",
    method: "post",
    data:{role_id}
  });
}
